<template>
  <el-card>
    <div slot="header">
      <span>查看供应商来访记录</span>
    </div>
    <el-row type="flex" justify="center">
      <el-col :span="14">
        <el-form
          class="table_form_wrap"
          ref="recordForm"
          :model="recordForm"
          label-width="140px"
        >
          <el-form-item label="供应商代码" prop="supplierCode">
            <el-input
              disabled
              v-model.trim="recordForm.supplierCode"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="供应商名称" prop="supplierName">
            <el-input
              disabled
              v-model.trim="recordForm.supplierName"
            />
          </el-form-item>
          <el-form-item label="采购归属" prop="belongDepartmentName">
            <el-input
              disabled
              v-model.trim="recordForm.belongDepartmentName"
            />
          </el-form-item>
          <el-form-item label="管理区域" prop="belongAreaName">
            <el-input
              disabled
              v-model.trim="recordForm.belongAreaName"
            />
          </el-form-item>
          <el-form-item label="来访人员" prop="visitPerson">
            <el-input
              disabled
              v-model.trim="recordForm.visitPersonName"
            />
          </el-form-item>
          <el-form-item label="来访人员联系方式" prop="visitPersonPhone">
            <el-input
              disabled
              v-model.trim="recordForm.visitPersonPhone"
            />
          </el-form-item>
          <el-form-item label="来访时间" prop="visitTime">
            <el-date-picker
              disabled
              v-model="recordForm.visitTime"
              type="date"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="接待人" prop="unawares">
            <el-input disabled v-model.trim="recordForm.unawares" placeholder="输入接待人" />
          </el-form-item>
          <el-form-item label="业务对接人" prop="businessCounterpart">
            <el-input
              disabled
              v-model.trim="recordForm.businessCounterpart"
            />
          </el-form-item>
          <el-form-item label="来访目的" prop="visitPurpose">
            <el-input
              disabled
              type="textarea"
              v-model.trim="recordForm.visitPurpose"
              show-word-limit
              :minlength="3"
              :maxlength="500"
            />
          </el-form-item>
          <el-form-item label="来访结果" prop="visitResult">
            <el-input
              disabled
              type="textarea"
              v-model.trim="recordForm.visitResult"
              show-word-limit
              :minlength="3"
              :maxlength="500"
            />
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row type="flex" justify="center">
      <el-button @click="handleCancel">返回</el-button>
    </el-row>
  </el-card>
</template>
<script>
import { queryRecordDetailService, getRecordBillByIdService } from '@api/supplier/returnVisteManage';
import { isResponseSuccess } from '@/pages/supplier/utils/bizUtils';

export default {
  data () {
    return {
      id: null,
      recordForm: {
        supplierId: '', // 供应商ID
        supplierCode: '', // 供应商代码
        supplierName: '', // 供应商名称
        belongDepartmentName: '', // 采购归属
        belongAreaName: '', // 供应商管理区域
        visitPersonName: '', // 来访人员
        visitPersonPhone: '', // 来访人员联系方式
        visitTime: '', // 来访时间
        unawares: '', // 创建人/接待人
        unawaresNo: '', // 创建人id
        businessCounterpart: '', // 业务对接人
        visitPurpose: '', // 来访目的
        visitResult: '', // 来访结果
      }
    }
  },
  created () {
    const { id, processId } = this.$route.query;
    if (processId) {
      this.getBillDetailById(id)
    } else if (id) {
      this.getDetailData(id)
    }
  },
  methods: {
    // 取消
    handleCancel () {
      this.$router.go(-1);
    },
    // 获取详情
    getDetailData (id) {
      queryRecordDetailService({ id }).then((res) => {
        if (isResponseSuccess(res)) {
          const { result } = res;
          this.recordForm = result;
        }
      })
    },
    // 获取详情
    getBillDetailById (id) {
      getRecordBillByIdService({ id }).then((res) => {
        if (isResponseSuccess(res)) {
          this.recordForm = res.result;
        }
      })
    },
  }
};
</script>
